package part14_迭代器模式_统一遍历问题;

import java.util.Iterator;

/**
 * @ClassName: ComputerCollege
 * @Author: AllenSun
 * @Date: 2020/3/8 12:18
 */
public class ComputerCollege implements Colleage {

    Department[] departments;
    int numOfDepaertment=0;

    public ComputerCollege() {
        departments=new Department[5];
        addDepartment("java专业","java专业");
        addDepartment("php专业","php专业");
        addDepartment("c专业","c专业");
    }

    @Override
    public String getName() {
        return "计算机学院";
    }

    @Override
    public void addDepartment(String name, String desc) {
        Department department=new Department(name,desc);
        departments[numOfDepaertment] = department;
        numOfDepaertment++;
    }

    @Override
    public Iterator createIterator() {
        return new ComputerCollegeIterator(departments);
    }
}
